import request from '@/config/axios'
import type {Dayjs} from 'dayjs';

/** 业务-运营-补单信息 */
export interface Business {
  id: number; // 编号
  registerTime?: string | Dayjs; // 登记时间
  shopId?: number; // 店铺
  refundTime: string | Dayjs; // 返款日期
  type?: string; // 类型
  refundMoney: number; // 返款金额
  orderMoney?: number; // 订单金额
  businessMoney: number; // 佣金金额
  giftCost: number; // 礼品成本
  oId?: string; // 订单号
  remark: string; // 备注
}

// 业务-运营-补单 API
export const BusinessApi = {
  // 查询业务-运营-补单分页
  getBusinessPage: async (params: any) => {
    return await request.get({url: `/operation/business/page`, params})
  },

  // 查询业务-运营-补单详情
  getBusiness: async (id: number) => {
    return await request.get({url: `/operation/business/get?id=` + id})
  },

  // 新增业务-运营-补单
  createBusiness: async (data: Business) => {
    return await request.post({url: `/operation/business/create`, data})
  },

  // 修改业务-运营-补单
  updateBusiness: async (data: Business) => {
    return await request.put({url: `/operation/business/update`, data})
  },

  // 删除业务-运营-补单
  deleteBusiness: async (id: number) => {
    return await request.delete({url: `/operation/business/delete?id=` + id})
  },

  /** 批量删除业务-运营-补单 */
  deleteBusinessList: async (ids: number[]) => {
    return await request.delete({url: `/operation/business/delete-list?ids=${ids.join(',')}`})
  },

  // 导出业务-运营-补单 Excel
  exportBusiness: async (params) => {
    return await request.download({url: `/operation/business/export-excel`, params})
  },

  getBusinessSum: async (params: any) => {
    return await request.get({url: `/operation/business/getBusinessSum`, params})
  },
}
